{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "48d47b8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "def ImageHist(image,type):\n",
    "    color=(255,255,255)\n",
    "    windowName = 'Gray'\n",
    "    if type ==31:\n",
    "        color = (255,0,0)\n",
    "        windowName = 'B Hist'\n",
    "    elif type == 32:\n",
    "        color = (0,255,0)\n",
    "        windowName = 'G Hist'\n",
    "    elif type == 33:\n",
    "        color = (0,0,255)\n",
    "        windowName = 'R Hist'\n",
    "    hist = cv2.calcHist([image],[0],None,[256],[0.0,255.0])\n",
    "    # 最大值最小值，及坐标\n",
    "    minV,maxV,minL,maxL = cv2.minMaxLoc(hist)\n",
    "    histImg = np.zeros([256,256,3],np.uint8)\n",
    "    for h in range(256):\n",
    "        intenNormal = int(hist[h]*256/maxV)\n",
    "        cv2.line(histImg,(h,256),(h,256-intenNormal),color)\n",
    "    cv2.imshow(windowName,histImg)\n",
    "    return histImg\n",
    "img = cv2.imread('image0.JPG',1)\n",
    "channels = cv2.split(img)\n",
    "\n",
    "for i in range(0,3):\n",
    "    ImageHist(channels[i],31+i)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b34c5372",
   "metadata": {},
   "source": [
    "直方图均衡化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d25db400",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "import random\n",
    "import math\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)\n",
    "\n",
    "dst = cv2.equalizeHist(gray)\n",
    "cv2.imshow('dst',dst)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "11294af4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#彩色直方图\n",
    "import cv2\n",
    "import numpy as np\n",
    "import random\n",
    "import math\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "(b,g,r) = cv2.split(img)\n",
    "\n",
    "bH = cv2.equalizeHist(b)\n",
    "gH = cv2.equalizeHist(g)\n",
    "rH = cv2.equalizeHist(r)\n",
    "dst = cv2.merge((bH,gH,rH))\n",
    "cv2.imshow('dst',dst)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b2ad1431",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#yuv 均衡化\n",
    "import cv2\n",
    "import numpy as np\n",
    "import random\n",
    "import math\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgYUV = cv2.cvtColor(img,cv2.COLOR_BGR2YUV)\n",
    "channelYUV = cv2.split(imgYUV)\n",
    "channelYUV[0] = cv2.equalizeHist(channelYUV[0])\n",
    "channels = cv2.merge(channelYUV)\n",
    "result = cv2.cvtColor(channels,cv2.COLOR_YCrCb2BGR)\n",
    "cv2.imshow('result',result)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ea0a3a1",
   "metadata": {},
   "source": [
    "灰度图像直方图源码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1f501be0",
   "metadata": {
    "scrolled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wiEgSdIYBoAkNcoAkKRGGQCS1CgDQJIaZQBIUqMMAElq1P8BZjzlmG6SHtMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import random\n",
    "import math\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)\n",
    "\n",
    "count = np.zeros(256,np.float)\n",
    "\n",
    "for i in range(0,height):\n",
    "    for j in range(0,width):\n",
    "        pixel = gray[i,j]\n",
    "        index = int(pixel)\n",
    "        count[index] = count[index]+1\n",
    "for i in range(0,255):\n",
    "    count[i] = count[i]/(height*width)\n",
    "x = np.linspace(0,255,256)\n",
    "y = count\n",
    "plt.bar(x,y,0.9,alpha=1,color='b')\n",
    "plt.show()\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "17884970",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD4CAYAAADlwTGnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAV0ElEQVR4nO3dYYwc533f8e+vVGkgrVva1SkhSKqkDdoAExgusaGJtkkRB0pJIfClLwpQbyQoQgjaZdAEcBIaAoL0neukDSpEoEAhhK3CkKCidnIvFMiCEURvTFtHQ6LFKrQurGudyVg0DKgthFpl/e+LG8Kr5e7t3N3y7nb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z3wAfAHYCrwCHtnq/7kA7vwPcPTDvc8CZ5v0Z4N9v9X6us22/CBwGXh3XNlYeOfIK8B7gQHPsd2x1GybQ3j8APj2k7FS3F9gNHG7evxf4dtOmmTu+q7R1y45tF3oAbR5lMatm4nEbVfUi8MOB2aPaNg88U1U/qqr/zsqdaUc2Yz8nZUR7R5nq9lbV9ar6ZvP+fwGvsfIEgZk7vqu0dZQ73tYuBMCox1TMmgK+kuRi8/gMGHjcBjD0cRtTalTbZvl4n26etnu+b0hkZtqbZD/wT4CvM+PHd6CtsEXHtgsBsOHHUUyJf1ZVh1l58uq/SfKLW71DW2RWj/dZ4IPAR4HrwH9o5s9Ee5P8feC/Ar9VVf9ztaJD5k1Ve4e0dcuObRcCoM2jLKZeVV1r/r4JfJmVruIsP25jVNtm8nhX1fer6v9V1Y+BJ/nJUMDUtzfJ32XlhPjFqvpSM3smj++wtm7lse1CALR5lMVUS/L3krz31nvgV4BXme3HbYxq2wJwIsl7khxg5TcqvrEF+zdRt06GjX/FyvGFKW9vkgB/CrxWVf+xb9HMHd9Rbd3SY7vVV8Y36er7/axccf8b4NGt3p870L4PsHK3wCvA5VttBP4RKz+283rz9/1bva/rbN/TrHSN/y8rn4oeWa1twKPNsb4CHN/q/Z9Qe/8z8C3gUnNi2D0L7QX+OSvDGpeAl5vX/bN4fFdp65YdWx8FIUkd1YUhIEnSEAaAJHWUASBJHWUASFJHGQCS1FEGgCR1lAEgSR31/wGNqXQcp7N3bgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD4CAYAAADlwTGnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAA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X3tQgDsAe70PV5l9D99VhXw+SRfai6fAfBHq/d5DJqf75ta6yZvrb7N8/Y+01xt92LfIZG56W+S/cCfBn6DOd++A32FKW3bLgTAhi9HMSP+XFUdonfl1ReS/Oi0GzQl87q9zwHvB54G7gGfbJbPRX+T/GHg3wH/sKp+f1TRIctmqr9D+jq1bduFAGhzKYuZV1V3m5/fBD5Lb6o4z5fbWKtvc7m9q+obVfV/q+o7wKf47qGAme9vkj9Ib0D8dFX9WrN4LrfvsL5Oc9t2IQDaXMpipiX5/iTveec+8GPAG8z35TbW6tsycDLJ9yU5QO87Kn5zCu2bqHcGw8aH6W1fmPH+Jgnwr4E3q+pf9K2au+27Vl+num2nfWZ8i86+n6B3xv13gBen3Z5N6N8P0nu3wOvAzXf6CPwRel+287Xm5w9Mu62P2b9fpTc1/j/09op+ZlTfgBebbX0LOD7t9k+ov/8G+DJwoxkYds9Df4E/T++wxg3genM7MY/bd0Rfp7ZtvRSEJHVUFw4BSZKGMAAkqaMMAEnqKANAkjrKAJCkjjIAJKmjDABJ6qj/Bw/LaBJ7MQ2NAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD4CAYAAADlwTGnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAVIklEQVR4nO3db4wc933f8fenVGkgrVva0SkhSLpkDMYAERgusaWF/knRBGpJIfClDwpITyQoQgnGVdEEcBMaAoz0meu0DSpEkCAjhK3CsKCidnMPFNCCUdRPzERHQ6LFKLQurGudyVg0DKgthFpl8+2DGzar1d7u7N3e7e3O+wUsbnfm95v9/W5mf5+Z2d3ZVBWSpO75S7NugCRpNgwASeooA0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lNoChl9uYU5v1bZHX92PN1XYv9J0SWZj+JjkK/E3gD1nw9TvQV5jRuu1CAGz7chRz4u9U1Uk2rrz6z5L8/KwbNCOLur6fAj4MfAy4CfzbZvpC9DfJXwX+E/BrVfU/RhUdMm2u+jukrzNbt10IgDaXsph7VXWj+fsm8FU2DhUX+XIbm/VtIdd3Vf2gqv5vVf058Hn+4lTA3Pc3yV9mY0D8UlV9pZm8kOt3WF9nuW67EABtLmUx15L8lSTvv3Mf+IfAqyz25TY269sK8ECS9yU5xsZvVPzRDNo3VXcGw8Y/ZmP9wpz3N0mA3wNeq6p/1zdr4dbvZn2d6bqd9Tvju/Tu+/1svOP+p8Djs27PDvTvZ9j4tMArwNU7fQR+ko0f23m9+fvBWbd1i/37MhuHxv+Hjb2iR0f1DXi8WdfXgDOzbv+U+vsfgG8DV5qB4eAi9Bf4u2yc1rgCvNzc7l/E9TuirzNbt14KQpI6qgungCRJQxgAktRRBoAkdZQBIEkdZQBIUkcZAJLUUQaAJHXU/wNSAfXsxBOnXgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 本质：统计每个像素灰度 出现的概率 0-255 p\n",
    "import cv2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "\n",
    "count_b = np.zeros(256,np.float)\n",
    "count_g = np.zeros(256,np.float)\n",
    "count_r = np.zeros(256,np.float)\n",
    "for i in range(0,height):\n",
    "    for j in range(0,width):\n",
    "        (b,g,r) = img[i,j]\n",
    "        index_b = int(b)\n",
    "        index_g = int(g)\n",
    "        index_r = int(r)\n",
    "        count_b[index_b] = count_b[index_b]+1\n",
    "        count_g[index_g] = count_g[index_g]+1\n",
    "        count_r[index_r] = count_r[index_r]+1\n",
    "for i in range(0,256):\n",
    "    count_b[i] = count_b[i]/(height*width)\n",
    "    count_g[i] = count_g[i]/(height*width)\n",
    "    count_r[i] = count_r[i]/(height*width)\n",
    "x = np.linspace(0,255,256)\n",
    "y = count_b\n",
    "plt.figure()\n",
    "plt.bar(x,y,0.9,alpha=1,color='b')\n",
    "y1 = count_g\n",
    "plt.figure()\n",
    "plt.bar(x,y1,0.9,alpha=1,color='g')\n",
    "y2 = count_r\n",
    "plt.figure()\n",
    "plt.bar(x,y2,0.9,alpha=1,color='r')\n",
    "plt.show()\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8a62400",
   "metadata": {},
   "source": [
    "直方图均衡化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "163307c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import random\n",
    "import math\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)\n",
    "\n",
    "count = np.zeros(256,np.float)\n",
    "\n",
    "for i in range(0,height):\n",
    "    for j in range(0,width):\n",
    "        pixel = gray[i,j]\n",
    "        index = int(pixel)\n",
    "        count[index] = count[index]+1\n",
    "for i in range(0,255):\n",
    "    count[i] = count[i]/(height*width)\n",
    "    \n",
    "sum1 = float(0)\n",
    "for i in range(0,256):\n",
    "    sum1 = sum1+count[i]\n",
    "    count[i] = sum1\n",
    "map1 = np.zeros(256,np.float)\n",
    "for i in range(0,256):\n",
    "    map1[i]=np.uint16(count[i]*255)\n",
    "for i in range(0,height):\n",
    "    for j in range(0,width):\n",
    "        pixel = gray[i,j]\n",
    "        gray[i,j] = map1[pixel]\n",
    "cv2.imshow('gray',gray)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "4d8f40e5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "\n",
    "count_b = np.zeros(256,np.float)\n",
    "count_g = np.zeros(256,np.float)\n",
    "count_r = np.zeros(256,np.float)\n",
    "for i in range(0,height):\n",
    "    for j in range(0,width):\n",
    "        (b,g,r) = img[i,j]\n",
    "        index_b = int(b)\n",
    "        index_g = int(g)\n",
    "        index_r = int(r)\n",
    "        count_b[index_b] = count_b[index_b]+1\n",
    "        count_g[index_g] = count_g[index_g]+1\n",
    "        count_r[index_r] = count_r[index_r]+1\n",
    "for i in range(0,256):\n",
    "    count_b[i] = count_b[i]/(height*width)\n",
    "    count_g[i] = count_g[i]/(height*width)\n",
    "    count_r[i] = count_r[i]/(height*width)\n",
    "sum_b = float(0)\n",
    "sum_g = float(0)\n",
    "sum_r = float(0)\n",
    "for i in range(0,256):\n",
    "    sum_b = sum_b+count_b[i]\n",
    "    sum_g = sum_g+count_g[i]\n",
    "    sum_r = sum_b+count_r[i]\n",
    "    count_b[i] = sum_b\n",
    "    count_g[i] = sum_g\n",
    "    count_r[i] = sum_r\n",
    "# 计算映射表\n",
    "map_b = np.zeros(256,np.uint16)\n",
    "map_g = np.zeros(256,np.uint16)\n",
    "map_r = np.zeros(256,np.uint16)\n",
    "for i in range(0,256):\n",
    "    map_b[i] = np.uint16(count_b[i]*255)\n",
    "    map_g[i] = np.uint16(count_g[i]*255)\n",
    "    map_r[i] = np.uint16(count_r[i]*255)\n",
    "\n",
    "dst = np.zeros((height,width,3),np.uint8)\n",
    "for i in range(0,height):\n",
    "    for j in range(0,width):\n",
    "        (b,g,r) = img[i,j]\n",
    "        b = map_b[b]\n",
    "        g = map_g[g]\n",
    "        r = map_r[r]\n",
    "        dst[i,j] = (b,g,r)\n",
    "cv2.imshow('dst',dst)\n",
    "cv2.waitKey()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
